package com.example.wire;

import java.util.LinkedList;
import java.util.Queue;

public class WireImpl implements Wire {
    private final Queue<Byte> sendStream;
    private final Queue<Byte> receiveStream;

    public WireImpl(){
        sendStream = new LinkedList<Byte>();
        receiveStream = new LinkedList<Byte>();
    }

    @Override
    public void sendByte(Byte b) {
        if (b!=null) {
            sendStream.offer(b);
        }
    }

    @Override
    public Byte receiveByte() {
        return receiveStream.poll();
    }

    @Override
    public Byte getFromSend() {
        return sendStream.poll();
    }

    @Override
    public void addToReceive(Byte b) {
        if (b!=null) {
            receiveStream.offer(b);
        }
    }

    @Override
    public Boolean isSendEmpty() {
        return sendStream.isEmpty();
    }

    @Override
    public Boolean isReceiveEmpty() {
        return receiveStream.isEmpty();
    }

}
